package com.tedu.parkinglot.equipment.controller;

import com.tedu.parkinglot.base.response.JsonResult;
import com.tedu.parkinglot.equipment.pojo.dto.EquipmentQuery;
import com.tedu.parkinglot.equipment.pojo.dto.EquipmentSaveParam;
import com.tedu.parkinglot.equipment.pojo.vo.EquipmentVO;
import com.tedu.parkinglot.equipment.service.EquipmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/equipment")
public class EquipmentController {
@Autowired
    EquipmentService equipmentService;

@GetMapping("select")
    public JsonResult selectEquipment(EquipmentQuery equipmentQuery){
    log.debug("查询参数EquipmentQuery:{}",equipmentQuery);
    List<EquipmentVO> list=equipmentService.selectEquipment(equipmentQuery);
    return JsonResult.ok(list);
}
@PostMapping("save")
    public JsonResult saveEquipment(EquipmentSaveParam equipmentSaveParam){
    equipmentService.saveEquipment(equipmentSaveParam);
    return JsonResult.ok();
}

@PostMapping("delete/{id}")
    public JsonResult deleteEquipment(@PathVariable Long id){
    log.debug("删除用户：id",id);
    equipmentService.deleteEquipment(id);
    return JsonResult.ok();
}
@PostMapping("update/status/{id}/{status}")
    public JsonResult updateStatus(
            @PathVariable Long id,@PathVariable String status
){
    log.debug("更新用户状态:id={},status={}",id,status);
    equipmentService.updateStatus(id,status);
    return JsonResult.ok();
}
}
